package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PremisesApiService;
import com.yixun.qfbao.apidto.GetBindPremisesResDto;
import com.yixun.qfbao.apidto.GetPartnerBindPremisesReqDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetPartnerBindPremisesReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 根据楼盘状态获取楼盘
 *
 * @classname: GetPremisesListByStatusHander.java
 * @author: Beau
 * @create: 2019/12/30 15:38
 * @version: 1.0.0
 **/
@Service("getPremisesListByStatusHander")
public class GetPremisesListByStatusHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetPremisesListByStatusHander.class);

    @Autowired
    private PremisesApiService premisesService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetPartnerBindPremisesReqVo req = (GetPartnerBindPremisesReqVo)reqDto;
        GetPartnerBindPremisesReqDto reqDto1 = req.getParams();
        BaseResponseDTO<GetBindPremisesResDto> res = new BaseResponseDTO<GetBindPremisesResDto>();
        GetBindPremisesResDto resDto = new GetBindPremisesResDto();

        try {
            resDto = premisesService.getPremisesListBySatus(reqDto1);
        } catch (Exception e) {
            logger.error("GetPremisesListByStatusHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("楼盘获取失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResultMsg());
        return res;
    }
}
